<template>
  <el-dialog :title="title" :visible="visible" width="500px" @close="close">
    <el-form
      ref="form"
      :model="entityData"
      :rules="rules"
      label-width="80px"
      label-position="right"
      style="width:90%;margin:0px auto;"
    >
      <!--表单区域 -->

      <el-form-item label="时区" prop="timeZone">
        <dictionary-select
          v-model="entityData.timeZone"
          :code="constant.DICTIONARY_TYPE_CODES.TIME_ZONE"
          :readonly="readonly"
          class="form-item"
        />
      </el-form-item>
      <el-form-item label="语种" prop="language">
        <dictionary-select
          v-model="entityData.language"
          :code="constant.DICTIONARY_TYPE_CODES.LANGUAGE"
          :readonly="readonly"
          class="form-item"
        />
      </el-form-item>
      <el-form-item label="桌面配置" prop="desktopConfig">
        <desktop-set
          v-model="entityData.desktopConfig"
          :readonly="readonly"
          class="form-item"
          @changeSelect="changeSelect"
        />
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button v-show="saveButtonVisible" type="primary" @click="save">保存</el-button>
      <el-button @click="close">关闭</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { detailMixin } from '@/mixin/detailMixin'
import DesktopSet from '@/components/popsoft/Portal/index'
const MODULE_CODE = 'system'
const ENTITY_TYPE = 'userProfile'
export default {
  name: ENTITY_TYPE + '-detail',
  components: { DesktopSet },
  mixins: [detailMixin],
  data() {
    return {
      entityType: ENTITY_TYPE,
      moduleCode: MODULE_CODE,
      // eslint-disable-next-line no-eval
      api: eval('this.$api.' + MODULE_CODE + '.' + ENTITY_TYPE),
      pageCode: MODULE_CODE + ':' + ENTITY_TYPE + ':',
      entityData: {

      },
      rules: {
        // 前端验证规则
        timeZone: [
          { required: true, message: '请选择时区', trigger: 'blur' }
        ],
        language: [
          { required: true, message: '请输选择语言', trigger: 'blur' }
        ]
      }
    }
  },
  methods: {
    // 展示
    show() {
      this.mode = 'modify'
      this.api.get()
        .then(res => {
          this.entityData = res.data
        })
      this.visible = true
    },
    changeSelect(value) {
      this.entityData.desktopConfig = value
    }

  }

}
</script>

<style lang="scss">
</style>
